package cn.edu.sdjzu.xg.eagle.entity;
import lombok.ToString;
@ToString
public class Pagination {
    private int pageSize = 5;
    private int pageNo = 2;
    private int totalNum = 6;

    public String toLimitClause(int totalNum) {
        this.totalNum = totalNum;
        int offset = (this.pageNo - 1) * this.pageSize;
        return " LIMIT " + offset + ", " + this.pageSize;
    }

    public Pagination(int pageSize, int pageNo) {
        if (pageNo>0){
            this.pageNo = pageNo;
        }
        if (pageSize>0){
            this.pageSize = pageSize;
        }
    }

    public Pagination() {
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(int totalNum) {
        this.totalNum = totalNum;
    }

}
